先看可以支援的語言
| \ | Drone | Travis | 
|---|---|---|
| 相同 | C / C++ Go Haskell (New) Groovy (New) Java Node.js PHP (Beta) Python (Beta) Ruby (Beta) Scala (New)  | 
C / C++ Go Haskell Groovy Java JavaScript (with Node.js) PHP Python Ruby Scala  | 
| 不同 | Dart | Android Clojure Erlang Objective-C Perl  | 
使用三步驟
- sign in Travis
 - Activate GitHub Webhook
 - Add .travis.yml file to your repository
 
驗證.travis.yml
- 可以透過這個Travis WebLint驗證
.travis.yml的正確性 - 或者可以安裝
travis-lint(requires Ruby 1.8.7+ and RubyGems install) 
# 安裝指令
gem install travis-lint
# Usage:
# inside a repository with .travis.yml
travis-lint
# from any directory
travis-lint [path to your .travis.yml]
travis-lint功能
- 提供驗證 
.travis.yml - 檢查 
language(請見上表) - 檢查特定的執行環境-VM-images)(見下方jdk)
 
# 例如Travis有提供`java`,沒有提供`Dart`
# 這樣就會報錯
# language: Dart
language: java
# 執行環境
jdk:
  - oraclejdk8
  - oraclejdk7
  - openjdk7
  - openjdk6
Configuring your build
Build Lifecycle
- Clone project repository from GitHub
 - cd to clone directory
 - Checkout commit for this build
 - Run 
before_installcommands
Use this to prepare the system to install prerequisites or dependencies
e.g.sudo apt-get update - Run 
installcommands
Use this to install any prerequisites or dependencies necessary to run your build - Run 
before_scriptcommands
Use this to prepare your build for testing
e.g. copy database configurations, environment variables, etc. - Run test 
scriptcommands
Default is specific to project language
All commands must exit with code 0 on success. Anything else is considered failure. - Run 
after_successorafter_failurecommands - Run 
after_scriptcommands 
Specify branches to build
可以指定git branch的白名單以及黑名單,也可以使用regualr expression
# blacklist
branches:
  except:
    - legacy
    - experimental
# whitelist
branches:
  only:
    - master
    - stable
    - /^deploy-.*$/
The Build Matrix
下面的範例來說,要build 56次
rvm:
  - 1.8.7
  - 1.9.2
  - 1.9.3
  - rbx-2
  - jruby
  - ruby-head
  - ree
gemfile:
  - gemfiles/Gemfile.rails-2.3.x
  - gemfiles/Gemfile.rails-3.0.x
  - gemfiles/Gemfile.rails-3.1.x
  - gemfiles/Gemfile.rails-edge
env:
  - ISOLATED=true
  - ISOLATED=false
You can also define exclusions to the build matrix:
matrix:
  exclude:
    - rvm: 1.8.7
      gemfile: gemfiles/Gemfile.rails-2.3.x
      env: ISOLATED=true
    - rvm: jruby
      gemfile: gemfiles/Gemfile.rails-2.3.x
      env: ISOLATED=true
Pre Install
Travis 本身有預先安裝一些東西,例如現在我想要使用 gradle 2.1,但是 Travis 現在提供的是 gradle 2.0,下面是更換 Travis 預設設定的方式。
before_install:
  - sudo rm -r /usr/local/gradle
  - curl -LO https://services.gradle.org/distributions/gradle-2.1-bin.zip
  - unzip -q gradle-2.1-bin.zip
  - sudo mv gradle-2.1 /usr/local/gradle
How to skip a build
並不是所有的 Commit 都需要進行 Travis Build,可以透過在 commit 的說明中(任何地方都可),添加[ci skip] or [skip ci]
Speeding up the build
Build Environment
這邊說明了 Travis 預設狀態下,事先安裝了什麼東西
Custom Deployment
Source:
- Travis CI build status badge on GitHub
 - shields
 - Travis CI 的 Deploy 功能
 - Travis CI
 - Travis-CI: What, Why, How
 - Get Your CI On with Travis CI
 
Command line:
Lint check your .travis.yml